﻿package com.wandian.view.components.ui.bank
{
	import com.wandian.ApplicationFacade;
	import com.wandian.controller.CLZNoticeName;
	import com.wandian.data.GameData;
	import com.wandian.util.CLZTxtTip;
	import com.wandian.util.TextControl;
	import com.wandian.view.components.ui.AddBtn;
	
	import flash.display.Sprite;
	import flash.events.Event;

    public class OpenBankPanel extends Object
    {
        private var _mcPanel:Sprite;
        private var _facade:ApplicationFacade;

        public function OpenBankPanel()
        {
            this._facade = ApplicationFacade.getInstance();
            return;
        }

        public function setPanel(param1:Sprite) : void
        {
            this._mcPanel = param1;
            this._mcPanel["setPwName_txt"].text = GameData.tip["SET_PW_NAME"];
            this._mcPanel["againPWName_txt"].text = GameData.tip["AGIAN_PW_NAME"];
            this._mcPanel["emailName_txt"].text = GameData.tip["EMAIL_ENTER"];
            this._mcPanel["numberName_txt"].text = GameData.tip["NUMBER_TELL_NAME"];
            AddBtn.addCurrentFunBtn(param1, this.commitHandler, GameData.tip["COMMIT"], 291, 330);
            this._mcPanel["setPw_txt"].restrict = "0-9a-zA-Z";
            this._mcPanel["againPW_txt"].restrict = "0-9a-zA-Z";
            this._mcPanel["number_txt"].restrict = "0-9";
            CLZTxtTip.addTip(this._mcPanel["setPw_txt"], GameData.tip["BANK_TIP_PW"]);
            CLZTxtTip.addTip(this._mcPanel["againPW_txt"], GameData.tip["BANK_TIP_AGAIN_PW"]);
            CLZTxtTip.addTip(this._mcPanel["email_txt"], GameData.tip["BANK_TIP_EMAIL"]);
            CLZTxtTip.addTip(this._mcPanel["number_txt"], GameData.tip["BANK_TIP_TELL"]);
            return;
        }

        private function commitHandler() : void
        {
            var _loc_1:* = this._mcPanel["setPw_txt"].text;
            var _loc_2:* = this._mcPanel["againPW_txt"].text;
            var _loc_3:* = this._mcPanel["email_txt"].text;
            var _loc_4:* = this._mcPanel["number_txt"].text;
            if (!TextControl.isSameForText(_loc_1, _loc_2))
            {
                CLZTxtTip.addTip(this._mcPanel["setPw_txt"], "<font color=\'#ff0000\'>" + GameData.tip["ENTER_PW_NOT_SAME"] + "</font>");
                CLZTxtTip.addTip(this._mcPanel["againPW_txt"], "<font color=\'#ff0000\'>" + GameData.tip["ENTER_PW_NOT_SAME"] + "</font>");
                return;
            }
            CLZTxtTip.removeTip(this._mcPanel["setPw_txt"]);
            CLZTxtTip.removeTip(this._mcPanel["againPW_txt"]);
            var _loc_5:* = TextControl.checkStrLen(_loc_1, 6, 12);
            if (_loc_5 != "")
            {
                CLZTxtTip.addTip(this._mcPanel["setPw_txt"], "<font color=\'#ff0000\'>" + _loc_5 + "</font>");
                return;
            }
            CLZTxtTip.removeTip(this._mcPanel["setPw_txt"]);
            if (!TextControl.isEmail(_loc_3))
            {
                CLZTxtTip.addTip(this._mcPanel["email_txt"], "<font color=\'#ff0000\'>" + GameData.tip["ENTER_EMAIL_IS_ERR"] + "</font>");
                return;
            }
            CLZTxtTip.removeTip(this._mcPanel["email_txt"]);
            CLZTxtTip.removeTip(this._mcPanel["number_txt"]);
            var _loc_6:Object = {pw:_loc_1, email:_loc_3, tell:_loc_4};
            this._facade.sendNotification(CLZNoticeName.BANK_COMMIT_OPEN_REQ, _loc_6);
            return;
        }

    }
}
